<?php
require_once("../config.php");
$fromwhere=$_SERVER['HTTP_REFERER'];
if(!isset($_GET['id'])) exit("no way");//header("location:$fromwhere");

$dsql->SetQuery("SELECT file,userid FROM pic  WHERE productid = ".$_GET['id']);
$dsql->Execute();
$allfiles=array();
while($row=$dsql->GetArray())
{
	$allfiles[]=$row['file'];
	$userid[]=$row['userid'];
}	
foreach($allfiles as $k=>$file)
{
	$username=$dsql->getone("select username from backuser where id = ".$userid[$k]);
	//echo $username;//
	rename(PICDIR.$username."/done/".$file,PICDIR."done/".$file);
}

$uid=new UID();
$data=array("status"=>"on");
$condition="id = ".$_GET['id'];
$uid->update("product",$data,$condition);
header("location:$fromwhere");

?>